home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / cell.bst < prev    next >
Text File  |  1992-07-19  |  32KB  |  1,360 lines

  1. % BibTex `jmb' bibliography style
  2. % version = 1.23 of cell.bst 1992 June 29 
  3. %                   Fix format.vol.num.pages to use field.or.null to
  4. %                   correctly handle case of missing volume.
  5. %                   [Nelson H. F. Beebe <beebe@plot79.math.utah.edu>]
  6. % version = 1.22 of cell.bst 1991 March 18
  7. % from version 1.20 of jmb.bst 1990 November 16
  8.  
  9. % The main difference is that there is no comma after the journal name!
  10.  
  11. % Thomas Schneider
  12. % National Cancer Institute
  13. % Laboratory of Mathematical Biology
  14. % Frederick, Maryland  21702-1013
  15. % toms@ncifcrf.gov
  16. %
  17. % This file is available by anonymous ftp from ncifcrf.gov in pub/delila.
  18. %
  19. % TITLES can be turned on and off!
  20. %      Just nocite the reference TitlesOn in the paper (i.e. \nocite{TitlesOn})
  21. %      and have a bibliography article in your database with that cite key!
  22. % Without titles is Journal of Molecular Biology;
  23. % With titles is Journal of Theoretical Biology.
  24. %
  25. % WARNING: Since I use mostly article, book and inproceedings, these
  26. % are formatted pretty closely to the Journal of Theoretical Biology style
  27. % while other things are neglected.  Also, I can't guarantee that the style
  28. % is exactly right.
  29. %
  30. % The following documentation is identical from the source of jmb.bst,
  31. % which was the apalike.bst taken from the Clarkson archive on 1989 June 19.
  32. %
  33. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  34. % BibTeX `apalike' bibliography style (24-Jan-88 version)
  35. % Adapted from the `alpha' style, version 0.99a; for BibTeX version 0.99a.
  36. % Copyright (C) 1988, all rights reserved.
  37. % Copying of this file is allowed, provided that if you make any changes at all
  38. % you name it something other than `apalike.bst'.
  39. % This restriction helps ensure that all copies are identical.
  40. % Differences between this style and `alpha' are generally heralded by a `%'.
  41. % The file btxbst.doc has the documentation for alpha.bst.
  42. %
  43. % This style should be used with the `apalike' LaTeX style (apalike.sty).
  44. % \cite's come out like "(Jones, 1986)" in the text but there are no labels
  45. % in the bibliography, and something like "(1986)" comes out immediately
  46. % after the author.  Author (and editor) names appear as last name, comma,
  47. % initials.  A `year' field is required for every entry, and so is either
  48. % an author (or in some cases, an editor) field or a key field.
  49. %
  50. % Editorial note:
  51. % Many journals require a style like `apalike', but I strongly, strongly,
  52. % strongly recommend that you not use it if you have a choice---use something
  53. % like `plain' instead.  Mary-Claire van Leunen (A Handbook for Scholars,
  54. % Knopf, 1979) argues convincingly that a style like `plain' encourages better
  55. % writing than one like `apalike'.  Furthermore the strongest arguments for
  56. % using an author-date style like `apalike'---that it's "the most practical"
  57. % (The Chicago Manual of Style, University of Chicago Press, thirteenth
  58. % edition, 1982, pages 400--401)---fall flat on their face with the new
  59. % computer-typesetting technology.  For instance page 401 anachronistically
  60. % states "The chief disadvantage of [a style like `plain'] is that additions
  61. % or deletions cannot be made after the manuscript is typed without changing
  62. % numbers in both text references and list."  LaTeX sidesteps the disadvantage.
  63. %
  64. % History:
  65. %   15-sep-86    (SK,OP)    Original version, by Susan King and Oren Patashnik.
  66. %   10-nov-86    (OP)    Truncated the sort.key$ string to the correct length
  67. %            in bib.sort.order to eliminate error message.
  68. %   24-jan-88    (OP)    Updated for BibTeX version 0.99a, from alpha.bst 0.99a;
  69. %            apalike now sorts by author, then year, then title;
  70. %            THIS `apalike' VERSION DOES NOT WORK WITH BIBTEX 0.98i.
  71. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  72. %
  73. % The program was further modified by Tom Schneider:
  74. %
  75. %   1989 June 19 (TDS)  Renamed jmb.bst.  Items that do not have years were
  76. %        listed in the bibliography without identifiers.  However, they
  77. %        have identifiers in the text.  The identifier was added.
  78. %        Titles were removed :-(.
  79.  
  80. %   1989 October 2 (TDS)  Made labels in the paper use the & symbol rather
  81. %                  than `and', as required by JMB.
  82. %   1989 October 3 (TDS)  Made et~al. be in italics.
  83. %                  Removed comma after journal name.  (actually, all
  84. %                  mid sentence commas go!)
  85. %                  Made volume number be bold faced.
  86. %                  Converted colon (:) after volume number to a comma (,).
  87. %                  If a journal name does NOT end in a period, add
  88. %                  a comma after the name.
  89. %   1989 October 14 (TDS)  Without a year the program used to sort on the
  90. %                   title.  I made it sort on the cite$ if there is no year.
  91. %   1989 October 18 (TDS)  If there is one reference without a year, put
  92. %                   an "a" at the end of its label, so that it comes out
  93. %                   as (Smith, a) in the text.  in FUNCTION {forward.pass}
  94. %   1989 November 2 (TDS)  Unpublished papers now give the title.
  95. %   1989 November 18 (TDS)  TITLES can be turned on and off!
  96. %                   Just nocite the reference TitlesOn in the paper
  97. %                   and have a bibliography article in your database
  98. %                   with that cite key!
  99. %   1989 December 5 (TDS)  I can't stand sorting to fall back on the
  100. %                   titles of the article - no control!  So in function
  101. %                   bib.sort.order the default is now cite$.
  102. %   1990 November 14 (TDS) Changes to match JTB better:
  103. %                    Names in the bibliography are now connected
  104. %                    with "\&" instead of "and", since this fits JTB better.
  105. %                    "In" is now "In:".
  106. %                    "editors" and "editor" are now "eds" and "ed".
  107. %                    booktitle follows editors.  editors in parenthesis.
  108. %                    pp. and p. instead of pages and page.
  109. %                    location followed by colon (:) and then publisher.
  110.  
  111. % for Cell:
  112. %   1991 March 13    Remove comma after journal name.
  113. %   1991 March 14    Journal names and et al are not in italics, no bf
  114. %                    \& goes back to 'and'.
  115.  
  116. ENTRY  % declare variables that have a value for each entry on the list
  117.   { address
  118.     author
  119.     booktitle
  120.     chapter
  121.     edition
  122.     editor
  123.     howpublished
  124.     institution
  125.     journal
  126.     key
  127. %    month        not used in apalike
  128.     note
  129.     number
  130.     organization
  131.     pages
  132.     publisher
  133.     school
  134.     series
  135.     title
  136.     type
  137.     volume
  138.     year
  139.   }
  140.   {}
  141.   { label extra.label sort.label }
  142.  
  143. INTEGERS { output.state before.all mid.sentence after.sentence after.block
  144.            docomma givetitles }
  145.  
  146. FUNCTION {init.state.consts}
  147. { #0 'before.all :=
  148.   #1 'mid.sentence :=
  149.   #2 'after.sentence :=
  150.   #3 'after.block :=
  151.  
  152.   #0 'docomma :=    % if it is 0 then don't do commas, otherwise do them.
  153. }
  154.  
  155. FUNCTION {init.toggle.switches}
  156. {% set switches for controlling the output!
  157.   #0 'givetitles := % if it is 0 then don't give titles, otherwise do them.
  158. }
  159.  
  160. STRINGS { s t }
  161.  
  162. FUNCTION {output.nonnull}
  163. { 's :=
  164.   output.state mid.sentence =
  165.  
  166. % %    { ", " * write$ }  % the comma here is responsible for every comma!
  167. % %                       % But JMB doesn't want commas, so away it goes!
  168. %      { " " * write$ }    % That does it!
  169.  
  170.     { % doing a comma is controlled specifically in JMB using docomma
  171.       docomma #0 =
  172.       { " " * write$ }
  173.       { ", " * write$ }
  174.       if$
  175.     }
  176.     { output.state after.block =
  177.     { add.period$ write$
  178.       newline$
  179.       "\newblock " write$
  180.     }
  181.     { output.state before.all =
  182.         'write$
  183.         { add.period$ " " * write$ }
  184.       if$
  185.     }
  186.       if$
  187.       mid.sentence 'output.state :=
  188.     }
  189.   if$
  190.   s
  191. }
  192.  
  193. FUNCTION {output}
  194. { duplicate$ empty$
  195.     'pop$
  196.     'output.nonnull
  197.   if$
  198. }
  199.  
  200. FUNCTION {output.check}
  201. { 't :=
  202.   duplicate$ empty$
  203.      {  t "title" =
  204.            { pop$ } % jmb ignores titles and does not object if missing
  205.            { pop$ "empty " t * " in " * cite$ * warning$ }
  206.         if$
  207.      }
  208.     'output.nonnull  % block periods
  209.     % { pop$  } % don't do anything
  210.   if$
  211. }
  212.  
  213. %    t "title" =
  214. %    { "zowie" warning$ }
  215. %    {  duplicate$ empty$
  216. %       { pop$ "EmPtY " t * " in " * cite$ * warning$ }
  217. %       'output.nonnull
  218. %    }
  219. %    if$
  220. %  if$
  221. %}
  222.  
  223. %                    apalike needs this function because
  224. %                    the year has special punctuation;
  225. %                    apalike ignores the month
  226. FUNCTION {output.year.check}
  227. { year empty$
  228.     {
  229.       "empty year in " cite$ ", using label: " extra.label * * * warning$
  230.       write$
  231.       " (" extra.label * ")" *
  232.       mid.sentence 'output.state :=
  233.     }
  234.     { write$
  235.       " (" year * extra.label * ")" *
  236.       mid.sentence 'output.state :=
  237.     }
  238.   if$
  239. }
  240.  
  241. FUNCTION {output.bibitem}
  242. { newline$
  243.   "\bibitem[" write$
  244.   label write$
  245.   "]{" write$
  246.   cite$ write$
  247.   "}" write$
  248.   newline$
  249.   ""
  250.   before.all 'output.state :=
  251. }
  252.  
  253. FUNCTION {fin.entry}
  254. { add.period$
  255.   write$
  256.   newline$
  257. }
  258.  
  259. FUNCTION {new.block}
  260. { output.state before.all =
  261.     'skip$
  262.     { after.block 'output.state := }
  263.   if$
  264. }
  265.  
  266. FUNCTION {new.sentence}
  267. { output.state after.block =
  268.     'skip$
  269.     { output.state before.all =
  270.     'skip$
  271.     { after.sentence 'output.state := }
  272.       if$
  273.     }
  274.   if$
  275. }
  276.  
  277. FUNCTION {not}
  278. {   { #0 }
  279.     { #1 }
  280.   if$
  281. }
  282.  
  283. FUNCTION {and}
  284. {   'skip$
  285.     { pop$ #0 }
  286.   if$
  287. }
  288.  
  289. FUNCTION {or}
  290. {   { pop$ #1 }
  291.     'skip$
  292.   if$
  293. }
  294.  
  295. FUNCTION {new.block.checkb}
  296. { empty$
  297.   swap$ empty$
  298.   and
  299.     'skip$
  300.     'new.block
  301.   if$
  302. }
  303.  
  304. FUNCTION {field.or.null}
  305. { duplicate$ empty$
  306.     { pop$ "" }
  307.     'skip$
  308.   if$
  309. }
  310.  
  311. FUNCTION {emphasize}
  312. { duplicate$ empty$
  313.     { pop$ "" }
  314. % nothing is emphasized in CELL!
  315. %    { "{\em " swap$ * "}" * }
  316.     { "{" swap$ * "}" * }
  317.   if$
  318. }
  319.  
  320. INTEGERS { nameptr namesleft numnames }
  321.  
  322. FUNCTION {format.names}
  323. { 's :=
  324.   #1 'nameptr :=
  325.   s num.names$ 'numnames :=
  326.   numnames 'namesleft :=
  327.     { namesleft #0 > }
  328.     { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=   % last name first
  329.       nameptr #1 >
  330.     { namesleft #1 >
  331.         { ", " * t * }
  332.         { numnames #2 >
  333.         { "," * }
  334.         'skip$
  335.           if$
  336.           t "others" =
  337. %        { " {\em et~al.}" * }  No emphasis in CELL!
  338.         { " {et~al.}" * }
  339. %        { " \& " * t * } not in CELL!
  340.         { " and " * t * }
  341.           if$
  342.         }
  343.       if$
  344.     }
  345.     't
  346.       if$
  347.       nameptr #1 + 'nameptr :=
  348.       namesleft #1 - 'namesleft :=
  349.     }
  350.   while$
  351. }
  352.  
  353. FUNCTION {format.authors}
  354. { author empty$
  355.     { "" }
  356.     { author format.names }
  357.   if$
  358. }
  359.  
  360. FUNCTION {format.key}            % this function is just for apalike
  361. { empty$
  362.     { key field.or.null }
  363.     { "" }
  364.   if$
  365. }
  366.  
  367. FUNCTION {format.editors}
  368. { editor empty$
  369.     { "" }
  370.     { editor format.names
  371.       editor num.names$ #1 >
  372.     { ", eds" * } % TDS
  373.     { ", ed" * } % TDS
  374.       if$
  375.     }
  376.   if$
  377. }
  378.  
  379. FUNCTION {format.title}
  380. { title empty$
  381.     { "" }
  382.     { % decide whether to give the title or not
  383.        givetitles #1 =
  384.        { title "t" change.case$ } % produce the title
  385.        { title pop$ "" }          % don't produce the title
  386.        if$
  387.     }
  388.   if$
  389. }
  390.  
  391. FUNCTION {n.dashify}
  392. { 't :=
  393.   ""
  394.     { t empty$ not }
  395.     { t #1 #1 substring$ "-" =
  396.     { t #1 #2 substring$ "--" = not
  397.         { "--" *
  398.           t #2 global.max$ substring$ 't :=
  399.         }
  400.         {   { t #1 #1 substring$ "-" = }
  401.         { "-" *
  402.           t #2 global.max$ substring$ 't :=
  403.         }
  404.           while$
  405.         }
  406.       if$
  407.     }
  408.     { t #1 #1 substring$ *
  409.       t #2 global.max$ substring$ 't :=
  410.     }
  411.       if$
  412.     }
  413.   while$
  414. }
  415.  
  416. FUNCTION {format.btitle}
  417. { title emphasize
  418. }
  419.  
  420. FUNCTION {tie.or.space.connect}
  421. { duplicate$ text.length$ #3 <
  422.     { "~" }
  423.     { " " }
  424.   if$
  425.   swap$ * *
  426. }
  427.  
  428. FUNCTION {either.or.check}
  429. { empty$
  430.     'pop$
  431.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  432.   if$
  433. }
  434.  
  435. FUNCTION {format.bvolume}
  436. { volume empty$
  437.     { "" }
  438.     { "volume" volume tie.or.space.connect
  439.       series empty$
  440.     'skip$
  441.     { " of " * series emphasize * }
  442.       if$
  443.       "volume and number" number either.or.check
  444.     }
  445.   if$
  446. }
  447.  
  448. FUNCTION {format.number.series}
  449. { volume empty$
  450.     { number empty$
  451.     { series field.or.null }
  452.     { output.state mid.sentence =
  453.         { "number" }
  454.         { "Number" }
  455.       if$
  456.       number tie.or.space.connect
  457.       series empty$
  458.         { "there's a number but no series in " cite$ * warning$ }
  459.         { " in " * series * }
  460.       if$
  461.     }
  462.       if$
  463.     }
  464.     { "" }
  465.   if$
  466. }
  467.  
  468. FUNCTION {format.edition}
  469. { edition empty$
  470.     { "" }
  471.     { output.state mid.sentence =
  472.     { edition "l" change.case$ " edition" * }
  473.     { edition "t" change.case$ " edition" * }
  474.       if$
  475.     }
  476.   if$
  477. }
  478.  
  479. INTEGERS { multiresult }
  480.  
  481. FUNCTION {multi.page.check}
  482. { 't :=
  483.   #0 'multiresult :=
  484.     { multiresult not
  485.       t empty$ not
  486.       and
  487.     }
  488.     { t #1 #1 substring$
  489.       duplicate$ "-" =
  490.       swap$ duplicate$ "," =
  491.       swap$ "+" =
  492.       or or
  493.     { #1 'multiresult := }
  494.     { t #2 global.max$ substring$ 't := }
  495.       if$
  496.     }
  497.   while$
  498.   multiresult
  499. }
  500.  
  501. FUNCTION {format.pages}
  502. { pages empty$
  503.     { "" }
  504.     { pages multi.page.check
  505.     { "pp." pages n.dashify tie.or.space.connect } % TDS
  506.     { "p." pages tie.or.space.connect } % TDS
  507.       if$
  508.     }
  509.   if$
  510. }
  511.  
  512. FUNCTION {format.vol.num.pages}
  513. % { "{\bf " volume "}" * * field.or.null  % make volume bold face NONE IN CELL
  514. { "{" volume field.or.null * "}" *  % make volume 
  515.   number empty$
  516.     'skip$
  517.     { " (" number * ")" * *
  518.        volume empty$
  519.     { "there's a number but no volume in " cite$ * warning$ }
  520.     'skip$
  521.       if$
  522.     }
  523.   if$
  524.   pages empty$
  525.     'skip$
  526.     { duplicate$ empty$
  527.     { pop$ format.pages }
  528. %    { ":" * pages n.dashify * } % no more colons after the volume
  529.     { ", " * pages n.dashify * } % comma's instead
  530.       if$
  531.     }
  532.   if$
  533. }
  534.  
  535. FUNCTION {format.chapter.pages}
  536. { chapter empty$
  537.     'format.pages
  538.     { type empty$
  539.     { "chapter" }
  540.     { type "l" change.case$ }
  541.       if$
  542.       chapter tie.or.space.connect
  543.       pages empty$
  544.     'skip$
  545.     { ", " * format.pages * }
  546.       if$
  547.     }
  548.   if$
  549. }
  550.  
  551. FUNCTION {format.in.ed.booktitle}
  552. { booktitle empty$
  553.     { "" }
  554.     { editor empty$
  555.     { "In: " booktitle emphasize * } % TDS
  556.     { "In: " booktitle emphasize * ", " *
  557.           "(" format.editors ")" * * * } % TDS
  558.       if$
  559.     }
  560.   if$
  561. }
  562.  
  563. FUNCTION {format.thesis.type}
  564. { type empty$
  565.     'skip$
  566.     { pop$
  567.       type "t" change.case$
  568.     }
  569.   if$
  570. }
  571.  
  572. FUNCTION {format.tr.number}
  573. { type empty$
  574.     { "Technical Report" }
  575.     'type
  576.   if$
  577.   number empty$
  578.     { "t" change.case$ }
  579.     { number tie.or.space.connect }
  580.   if$
  581. }
  582.  
  583. FUNCTION {format.article.crossref}
  584. { "In:"                % this is for apalike % TDS
  585.   " \cite{" * crossref * "}" *
  586. }
  587.  
  588. FUNCTION {format.book.crossref}
  589. { volume empty$
  590.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  591.       "In: " % TDS
  592.     }
  593.     { "Volume" volume tie.or.space.connect
  594.       " of " *
  595.     }
  596.   if$
  597.   "\cite{" * crossref * "}" *                % this is for apalike
  598. }
  599.  
  600. FUNCTION {format.incoll.inproc.crossref}
  601. { "In:"                % this is for apalike % TDS
  602.   " \cite{" * crossref * "}" *
  603. }
  604.  
  605. FUNCTION {article}
  606. {
  607.   cite$ "TitlesOn" =
  608.   'skip$ % Don't write out an article of this kind, it's a toggle switch!
  609.   {
  610.   output.bibitem
  611.   format.authors "author" output.check
  612.   author format.key output                % special for
  613.   output.year.check                    % apalike
  614.   new.block
  615.   format.title "title" output.check
  616.   new.block
  617.   crossref missing$
  618.     { % figure out the last character of the journal name.
  619.       % "<<" journal #-1 #1 substring$ ">>" * *  % for testing
  620.       % "<" journal ">" * *  % this works ok     % for testing
  621.  
  622.       journal #-1 #1 substring$ "." =
  623.       { journal }  % journal ended in period so don't do anything
  624. % the old jmb way:
  625. %      { journal ", " *}  % journal ended without period, so add comma
  626. % the new cell way:
  627.       { journal }  % journal ended without period, so DON'T add comma
  628.       if$
  629.       emphasize "journal" output.check
  630.  
  631. %      journal * emphasize "journal" output.check % the original method
  632.  
  633.       format.vol.num.pages output
  634.     }
  635.     { format.article.crossref output.nonnull
  636.       format.pages output
  637.     }
  638.   if$
  639.   new.block
  640.   note output
  641.   fin.entry
  642.   }
  643.   if$
  644. }
  645.  
  646. FUNCTION {book}
  647. { output.bibitem
  648.   author empty$
  649.     { format.editors "author and editor" output.check
  650.       editor format.key output
  651.     }
  652.     { format.authors output.nonnull
  653.       crossref missing$
  654.     { "author and editor" editor either.or.check }
  655.     'skip$
  656.       if$
  657.     }
  658.   if$
  659.   output.year.check                % special for apalike
  660.   new.block
  661.   format.btitle "title" output.check
  662.   #1 'docomma :=    % TURN COMMAS ON FOR JMB
  663.   crossref missing$
  664.     {
  665.       format.bvolume output
  666.       new.block
  667.       format.number.series output
  668.       new.sentence
  669.          #0 'docomma := % no comma after address
  670.       address ":" * output % TDS
  671.       publisher "publisher" output.check % TDS
  672.          #1 'docomma := % comma back on
  673. %      publisher "publisher" output.check
  674. %      address output
  675.     }
  676.     { new.block
  677.       format.book.crossref output.nonnull
  678.     }
  679.   if$
  680.   format.edition output
  681.   new.block
  682.   note output
  683.   fin.entry
  684.   #0 'docomma :=    % TURN COMMAS OFF
  685. }
  686.  
  687. FUNCTION {booklet}
  688. { output.bibitem
  689.   format.authors output
  690.   author format.key output                % special for
  691.   output.year.check                    % apalike
  692.   new.block
  693.   format.title "title" output.check
  694.   new.block
  695.   howpublished output
  696.   address output
  697.   new.block
  698.   note output
  699.   fin.entry
  700. }
  701.  
  702. FUNCTION {inbook}
  703. { output.bibitem
  704.   author empty$
  705.     { format.editors "author and editor" output.check
  706.       editor format.key output
  707.     }
  708.     { format.authors output.nonnull
  709.       crossref missing$
  710.     { "author and editor" editor either.or.check }
  711.     'skip$
  712.       if$
  713.     }
  714.   if$
  715.   output.year.check                % special for apalike
  716.   new.block
  717.   format.btitle "title" output.check
  718.   crossref missing$
  719.     { format.bvolume output
  720.       format.chapter.pages "chapter and pages" output.check
  721.       new.block
  722.       format.number.series output
  723.       new.sentence
  724.          #0 'docomma := % no comma after address
  725.       address ":" * output % TDS
  726.       publisher "publisher" output.check % TDS
  727.          #1 'docomma := % comma back on
  728. %      publisher "publisher" output.check
  729. %      address output
  730.     }
  731.     { format.chapter.pages "chapter and pages" output.check
  732.       new.block
  733.       format.book.crossref output.nonnull
  734.     }
  735.   if$
  736.   format.edition output
  737.   new.block
  738.   note output
  739.   fin.entry
  740. }
  741.  
  742. FUNCTION {incollection}
  743. { output.bibitem
  744.   format.authors "author" output.check
  745.   author format.key output                % special for
  746.   output.year.check                    % apalike
  747.   new.block
  748.   format.title "title" output.check
  749.   new.block
  750.   crossref missing$
  751.     { format.in.ed.booktitle "booktitle" output.check
  752.       format.bvolume output
  753.       format.number.series output
  754.       format.chapter.pages output
  755.       new.sentence
  756.       publisher "publisher" output.check
  757.       address output
  758.       format.edition output
  759.     }
  760.     { format.incoll.inproc.crossref output.nonnull
  761.       format.chapter.pages output
  762.     }
  763.   if$
  764.   new.block
  765.   note output
  766.   fin.entry
  767. }
  768.  
  769. FUNCTION {inproceedings}
  770. { output.bibitem
  771.   format.authors "author" output.check
  772.   author format.key output                % special for
  773.   output.year.check                    % apalike
  774.   new.block
  775.   format.title "title" output.check
  776.   new.block
  777.   crossref missing$
  778.     {
  779. %      #1 'docomma :=    % TURN COMMAS ON FOR JMB, BUT NOT FOR JTB: inconsistent
  780.       format.in.ed.booktitle "booktitle" output.check
  781.       format.bvolume output
  782.       format.number.series output
  783.       format.pages "," * output % TDS toss in comma instead of period
  784. %      address output % TDS address is below for JTB
  785. %      new.sentence % TDS remove period
  786.       organization output
  787.          #0 'docomma := % NO COMMA AFTER ADDRESS
  788.       address ":" * output % TDS
  789.       publisher "publisher" output.check % TDS
  790.          #1 'docomma := % comma back on
  791.  
  792. %      publisher output                    % are simpler
  793.       #0 'docomma :=    % TURN COMMAS OFF
  794.     }
  795.     { format.incoll.inproc.crossref output.nonnull
  796.       format.pages output
  797.     }
  798.   if$
  799.   new.block
  800.   note output
  801.   fin.entry
  802. }
  803.  
  804. FUNCTION {conference} { inproceedings }
  805.  
  806. FUNCTION {manual}
  807. { output.bibitem
  808.   format.authors output
  809.   author format.key output                % special for
  810.   output.year.check                    % apalike
  811.   new.block
  812.   format.btitle "title" output.check
  813.   organization address new.block.checkb
  814.   organization output
  815.   address output
  816.   format.edition output
  817.   new.block
  818.   note output
  819.   fin.entry
  820. }
  821.  
  822. FUNCTION {mastersthesis}
  823. { output.bibitem
  824.   format.authors "author" output.check
  825.   author format.key output                % special for
  826.   output.year.check                    % apalike
  827.   new.block
  828.   format.title "title" output.check
  829.   new.block
  830.   "Master's thesis" format.thesis.type output.nonnull
  831.   school "school" output.check
  832.   address output
  833.   new.block
  834.   note output
  835.   fin.entry
  836. }
  837.  
  838. FUNCTION {misc}
  839. { output.bibitem
  840.   format.authors output
  841.   author format.key output                % special for
  842.   output.year.check                    % apalike
  843.   new.block
  844.   format.title output
  845.   new.block
  846.   howpublished output
  847.   new.block
  848.   note output
  849.   fin.entry
  850. }
  851.  
  852. FUNCTION {phdthesis}
  853. { output.bibitem
  854.   format.authors "author" output.check
  855.   author format.key output                % special for
  856.   output.year.check                    % apalike
  857.   new.block
  858.   format.btitle "title" output.check
  859.   new.block
  860.   "PhD thesis" format.thesis.type output.nonnull
  861.   school "school" output.check
  862.   address output
  863.   new.block
  864.   note output
  865.   fin.entry
  866. }
  867.  
  868. FUNCTION {proceedings}
  869. { output.bibitem
  870.   format.editors output
  871.   editor format.key output                % special for
  872.   output.year.check                    % apalike
  873.   new.block
  874.   format.btitle "title" output.check
  875.   format.bvolume output
  876.   format.number.series output
  877.   address output                % for apalike
  878.   new.sentence                    % we always output
  879.   organization output                % a nonempty organization
  880.   publisher output                % here
  881.   new.block
  882.   note output
  883.   fin.entry
  884. }
  885.  
  886. FUNCTION {techreport}
  887. { output.bibitem
  888.   format.authors "author" output.check
  889.   author format.key output                % special for
  890.   output.year.check                    % apalike
  891.   new.block
  892.   format.title "title" output.check
  893.   new.block
  894.   format.tr.number output.nonnull
  895.   institution "institution" output.check
  896.   address output
  897.   new.block
  898.   note output
  899.   fin.entry
  900. }
  901.  
  902. FUNCTION {unpublished}
  903. { output.bibitem
  904.   format.authors "author" output.check
  905.   author format.key output                % special for
  906.   output.year.check                    % apalike
  907.   new.block
  908.  
  909. % Since format.title is out of commission, the original method won't work:
  910. %  format.title "title" output.check
  911. % so do the equivalent of the format.title procedure: (TDS)
  912.   title empty$
  913.     { "" }
  914.     { title "t" change.case$ } % produce the title
  915.   if$
  916.   "title" output.check
  917.  
  918.   new.block
  919.   note "note" output.check
  920.   fin.entry
  921. }
  922.  
  923. FUNCTION {default.type} { misc }
  924.  
  925. MACRO {jan} {"January"}
  926.  
  927. MACRO {feb} {"February"}
  928.  
  929. MACRO {mar} {"March"}
  930.  
  931. MACRO {apr} {"April"}
  932.  
  933. MACRO {may} {"May"}
  934.  
  935. MACRO {jun} {"June"}
  936.  
  937. MACRO {jul} {"July"}
  938.  
  939. MACRO {aug} {"August"}
  940.  
  941. MACRO {sep} {"September"}
  942.  
  943. MACRO {oct} {"October"}
  944.  
  945. MACRO {nov} {"November"}
  946.  
  947. MACRO {dec} {"December"}
  948.  
  949. MACRO {acmcs} {"ACM Computing Surveys"}
  950.  
  951. MACRO {acta} {"Acta Informatica"}
  952.  
  953. MACRO {cacm} {"Communications of the ACM"}
  954.  
  955. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  956.  
  957. MACRO {ibmsj} {"IBM Systems Journal"}
  958.  
  959. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  960.  
  961. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  962.  
  963. MACRO {ieeetcad}
  964.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  965.  
  966. MACRO {ipl} {"Information Processing Letters"}
  967.  
  968. MACRO {jacm} {"Journal of the ACM"}
  969.  
  970. MACRO {jcss} {"Journal of Computer and System Sciences"}
  971.  
  972. MACRO {scp} {"Science of Computer Programming"}
  973.  
  974. MACRO {sicomp} {"SIAM Journal on Computing"}
  975.  
  976. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  977.  
  978. MACRO {tods} {"ACM Transactions on Database Systems"}
  979.  
  980. MACRO {tog} {"ACM Transactions on Graphics"}
  981.  
  982. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  983.  
  984. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  985.  
  986. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  987.  
  988. MACRO {tcs} {"Theoretical Computer Science"}
  989.  
  990. READ
  991.  
  992. % ***********************************************************
  993.  
  994. FUNCTION {check.for.titlecommand}
  995. % go through each entry and see if one of them has the key
  996. % 'TitlesOn'.  If this is found, then do titles!
  997. % 1989 November 18 TDS
  998. {
  999. %  "|" label "|" * * write$ newline$  % |Arrhenius {\em et~al.}, 1986|
  1000. %  "|" cite$ "|" * * write$ newline$  % |Arrhenius1986|
  1001. % so cite$ is the thing I want to detect...
  1002.  
  1003.   cite$ "TitlesOn" =
  1004.   { % got it!
  1005. %    "FOUND TitlesOn" write$ newline$
  1006.      "Titles Will Be Printed" warning$
  1007.     #1 'givetitles := % give titles!
  1008.   }
  1009.   'skip$
  1010.   if$
  1011. }
  1012. EXECUTE {init.toggle.switches}
  1013. ITERATE {check.for.titlecommand}
  1014. % ***********************************************************
  1015.  
  1016. FUNCTION {sortify}
  1017. { purify$
  1018.   "l" change.case$
  1019. }
  1020.  
  1021. INTEGERS { len }
  1022.  
  1023. FUNCTION {chop.word}
  1024. { 's :=
  1025.   'len :=
  1026.   s #1 len substring$ =
  1027.     { s len #1 + global.max$ substring$ }
  1028.     's
  1029.   if$
  1030. }
  1031.  
  1032. %            There are three apalike cases: one person (Jones),
  1033. %            two (Jones and de~Bruijn), and more (Jones et~al.).
  1034. %            This function is much like format.crossref.editors.
  1035. %
  1036. FUNCTION {format.lab.names}
  1037. { 's :=
  1038.   s #1 "{vv~}{ll}" format.name$
  1039.   s num.names$ duplicate$
  1040.   #2 >
  1041. %    { pop$ " {\em et~al.}" * } no em in CELL!
  1042.     { pop$ " {et~al.}" * }
  1043.     { #2 <
  1044.     'skip$
  1045.     { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  1046. %        { " {\em et~al.}" * } no em in CELL!
  1047.         { " {et~al.}" * }
  1048. %        { " \& " * s #2 "{vv~}{ll}" format.name$ * } not in CELL!
  1049.             % note new use of & rather than `and'.  TDS not in CELL!
  1050.         { " and " * s #2 "{vv~}{ll}" format.name$ * }
  1051.       if$
  1052.     }
  1053.       if$
  1054.     }
  1055.   if$
  1056. }
  1057.  
  1058. FUNCTION {author.key.label}
  1059. { author empty$
  1060.     { key empty$
  1061.     { cite$ #1 #3 substring$ }
  1062.     'key                    % apalike uses the whole key
  1063.       if$
  1064.     }
  1065.     { author format.lab.names }
  1066.   if$
  1067. }
  1068.  
  1069. FUNCTION {author.editor.key.label}
  1070. { author empty$
  1071.     { editor empty$
  1072.     { key empty$
  1073.         { cite$ #1 #3 substring$ }
  1074.         'key                % apalike uses the whole key
  1075.       if$
  1076.     }
  1077.     { editor format.lab.names }
  1078.       if$
  1079.     }
  1080.     { author format.lab.names }
  1081.   if$
  1082. }
  1083.  
  1084. FUNCTION {editor.key.label}
  1085. { editor empty$
  1086.     { key empty$
  1087.     { cite$ #1 #3 substring$ }
  1088.     'key            % apalike uses the whole key, no organization
  1089.       if$
  1090.     }
  1091.     { editor format.lab.names }
  1092.   if$
  1093. }
  1094.  
  1095. FUNCTION {calc.label}
  1096. { type$ "book" =
  1097.   type$ "inbook" =
  1098.   or
  1099.     'author.editor.key.label
  1100.     { type$ "proceedings" =
  1101.     'editor.key.label            % apalike ignores organization
  1102.     'author.key.label            % for labeling and sorting
  1103.       if$
  1104.     }
  1105.   if$
  1106.   ", "                            % these three lines are
  1107.   *                            % for apalike, which
  1108.   year field.or.null purify$ #-1 #4 substring$        % uses all four digits
  1109.   *
  1110.   'label :=
  1111. }
  1112.  
  1113. FUNCTION {sort.format.names}
  1114. { 's :=
  1115.   #1 'nameptr :=
  1116.   ""
  1117.   s num.names$ 'numnames :=
  1118.   numnames 'namesleft :=
  1119.     { namesleft #0 > }
  1120.     { nameptr #1 >
  1121.     { "   " * }
  1122.     'skip$
  1123.       if$                        % apalike uses initials
  1124.       s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ 't := % <= here
  1125.       nameptr numnames = t "others" = and
  1126. %    { "{\em et al}" * } % not in CELL!
  1127.     { "{et~al}" * }
  1128.     { t sortify * }
  1129.       if$
  1130.       nameptr #1 + 'nameptr :=
  1131.       namesleft #1 - 'namesleft :=
  1132.     }
  1133.   while$
  1134. }
  1135.  
  1136. FUNCTION {sort.format.title}
  1137. { 't :=
  1138.   "A " #2
  1139.     "An " #3
  1140.       "The " #4 t chop.word
  1141.     chop.word
  1142.   chop.word
  1143.   sortify
  1144.   #1 global.max$ substring$
  1145. }
  1146.  
  1147. FUNCTION {author.sort}
  1148. { author empty$
  1149.     { key empty$
  1150.     { "to sort, need author or key in " cite$ * warning$
  1151.       ""
  1152.     }
  1153.     { key sortify }
  1154.       if$
  1155.     }
  1156.     { author sort.format.names }
  1157.   if$
  1158. }
  1159.  
  1160. FUNCTION {author.editor.sort}
  1161. { author empty$
  1162.     { editor empty$
  1163.     { key empty$
  1164.         { "to sort, need author, editor, or key in " cite$ * warning$
  1165.           ""
  1166.         }
  1167.         { key sortify }
  1168.       if$
  1169.     }
  1170.     { editor sort.format.names }
  1171.       if$
  1172.     }
  1173.     { author sort.format.names }
  1174.   if$
  1175. }
  1176.  
  1177. FUNCTION {editor.sort}
  1178. { editor empty$
  1179.     { key empty$
  1180.     { "to sort, need editor or key in " cite$ * warning$
  1181.       ""
  1182.     }
  1183.     { key sortify }
  1184.       if$
  1185.     }
  1186.     { editor sort.format.names }
  1187.   if$
  1188. }
  1189.  
  1190. %            apalike uses two sorting passes; the first one sets the
  1191. %            labels so that the `a's, `b's, etc. can be computed;
  1192. %            the second pass puts the references in "correct" order.
  1193. %            The presort function is for the first pass. It computes
  1194. %            label, sort.label, and title, and then concatenates.
  1195. FUNCTION {presort}
  1196. { calc.label
  1197.   label sortify
  1198.   "    "
  1199.   *
  1200.   type$ "book" =
  1201.   type$ "inbook" =
  1202.   or
  1203.     'author.editor.sort
  1204.     { type$ "proceedings" =
  1205.     'editor.sort
  1206.     'author.sort
  1207.       if$
  1208.     }
  1209.   if$
  1210.   #1 entry.max$ substring$    % for
  1211.   'sort.label :=        % apalike
  1212.   sort.label            % style
  1213.   *
  1214.   "    "
  1215.   *
  1216.   title field.or.null
  1217.   sort.format.title
  1218.   *
  1219.   #1 entry.max$ substring$
  1220.   'sort.key$ :=
  1221. }
  1222.  
  1223. ITERATE {presort}
  1224.  
  1225. SORT        % by label, sort.label, title---for final label calculation
  1226.  
  1227. STRINGS { last.label next.extra }    % apalike labels are only for the text;
  1228.  
  1229. INTEGERS { last.extra.num }        % there are none in the bibliography
  1230.  
  1231. FUNCTION {initialize.extra.label.stuff}    % and hence there is no `longest.label'
  1232. { #0 int.to.chr$ 'last.label :=
  1233.   "" 'next.extra :=
  1234.   #0 'last.extra.num :=
  1235. }
  1236.  
  1237. FUNCTION {forward.pass}
  1238. % pass through the references forward
  1239. {
  1240. %"\\     label=" label "//" * * write$ newline$ % display the label
  1241. %"\\last.label=" last.label "//" * * write$ newline$ % display the label
  1242.  
  1243.  last.label label =   % if the label repeats the previous label...
  1244.     { % then increment the extra number
  1245.       last.extra.num #1 + 'last.extra.num :=
  1246.       % and convert it to a label
  1247.       last.extra.num int.to.chr$ 'extra.label :=
  1248.     }
  1249.     { % else set things up for the next entry
  1250.       "a" chr.to.int$ 'last.extra.num :=
  1251.  
  1252.       % However, if the year was missing, tack on an extra "a". TDS
  1253.       year empty$
  1254.       {"a" 'extra.label :=}
  1255.       {"" 'extra.label :=}
  1256.       if$
  1257.  
  1258. %      "" 'extra.label :=  % the original method was not to do anything TDS
  1259.  
  1260.       label 'last.label :=   % capture this label for next time
  1261.     }
  1262.   if$
  1263. %"\\extra.label = " extra.label "//" * * write$ newline$ % display the label
  1264. }
  1265.  
  1266. FUNCTION {reverse.pass}
  1267. % pass through the references backwards
  1268. % add extra characters to the end of the label string
  1269. {
  1270. %"{{" label "}}" * * write$ newline$ % display the label
  1271.  next.extra "b" =
  1272. % original logic:
  1273.     { "a" 'extra.label := }
  1274.     'skip$
  1275.     if$
  1276.  
  1277. % next.extra "b" = { "next.extra was = b" write$ newline$} 'skip$ if$
  1278.  
  1279. % new as of 1989 Oct 18
  1280. %    { "a" 'extra.label := }
  1281. %    { % Put on an "a" at the end of the label if the year is missing. TDS
  1282. %      year empty$
  1283. %       { "a" 'extra.label := }
  1284. %       %{ label "a" * 'label := }
  1285. %       'skip$ % otherwise leave it alone (orignial method)
  1286. %     if$ }
  1287. %  if$
  1288.  
  1289.   label extra.label * 'label :=
  1290.   extra.label 'next.extra :=
  1291. %"{{" label "}}" * * write$ newline$ % display the label
  1292. }
  1293.  
  1294. FUNCTION {bib.sort.order}
  1295. % Generate the sort.key$ variables for sorting.
  1296. % The sorting is first on the sort.label (ie, author's name), followed
  1297. % by the year then the title.  If there is no year, the cite$ is used.
  1298. {
  1299.   sort.label  % this is based on the author name
  1300.   "    " * % tack on some space
  1301. % original apa command was to use the year or an empty string:
  1302. %  year field.or.null sortify
  1303. % Replace that with the use of the cite$, when there is no year:
  1304.   year duplicate$ empty$
  1305.      {pop$ cite$}
  1306.      'skip$
  1307.   if$
  1308.  
  1309.   * "    " *  % tack on some space
  1310.  
  1311. % I CAN'T STAND SORTING ON TITLE!!! TDS 1989 Dec 5
  1312. %  title field.or.null
  1313. %  sort.format.title
  1314. %  * % attach them together
  1315.   cite$
  1316.   * % use cite$ instead!!
  1317.  
  1318.   % note: if there is no year, then the cite$ will override the sorting
  1319.   % on the title.  Oh well.  Title sorting is sorta (ha ha) awful.
  1320.  
  1321.   #1 entry.max$ substring$
  1322.   'sort.key$ :=
  1323.  
  1324.   % The following line helps debug the program.  It shows what the sort.key$ is.
  1325.   % "%" sort.key$ * write$ newline$
  1326. }
  1327.  
  1328. % Here is the place that the actual executions of the labeling and sorting
  1329. % functions are done.
  1330.  
  1331.  
  1332. EXECUTE {initialize.extra.label.stuff} % initialize variables
  1333. ITERATE {bib.sort.order}               % set up the sorting keys
  1334. SORT        % by sort.label, year, title---giving final bibliography order
  1335. % Having sorted NOW we apply the extra letters at the end!
  1336. ITERATE {forward.pass}
  1337. REVERSE {reverse.pass}
  1338.  
  1339. FUNCTION {begin.bib}
  1340. { preamble$ empty$                % no \etalchar in apalike
  1341.     'skip$
  1342.     { preamble$ write$ newline$ }
  1343.   if$
  1344.   "\begin{thebibliography}{}" write$ newline$        % no labels in apalike
  1345. }
  1346.  
  1347. EXECUTE {begin.bib}
  1348.  
  1349. EXECUTE {init.state.consts}
  1350.  
  1351. ITERATE {call.type$}
  1352.  
  1353. FUNCTION {end.bib}
  1354. { newline$
  1355.   "\end{thebibliography}" write$ newline$
  1356. }
  1357.  
  1358. EXECUTE {end.bib}
  1359.